Skip to content

Encapsulate games under games/ with catalog session identities - #411

Open
bramcohen wants to merge 12 commits into
mainfrom
encapsulate-games
Open

Encapsulate games under games/ with catalog session identities#411
bramcohen wants to merge 12 commits into
mainfrom
encapsulate-games

Conversation

@bramcohen

@bramcohen bramcohen commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Move each game into games/<key>/{clsp,rust,ui} behind a portable games/host contract and games/registry.json.
  • Keep catalog keys (calpoker, spacepoker, krunk) in the JS session model and IndexedDB; factory hashes stay on the WASM propose/notify boundary.
  • Make lastTerms null until a hand is agreed so compose drafts and last terms persist independently and round-trip.

Test plan

  • pnpm --filter chia-gaming-fe run test
  • ./ct.sh (or CI) for Rust/simulator coverage
  • Fresh local session: compose an unsubmittable draft, reload, confirm it restores and lastTerms stays null
  • Play one hand, reload mid-session, confirm catalog gameType in the save and the game remounts
  • Propose/accept across bind/warmup so ProposalMade is held until protocol identities are ready

Note

High Risk
Touches session persistence (envelope v15), proposal/identity mapping at the WASM boundary, and the entire game UI/lifecycle path. A mismatch in catalog vs protocol IDs or pending-candidate handling can break play and restore.

Overview
Turns games into self-contained packages under games/<key>/{clsp,rust,ui}, registered only in games/registry.json. Rust and frontend wiring, CLVM compile, presets, and tests are generated from that catalog. Core no longer special-cases Calpoker/Krunk/Space Poker when composing or reviewing.

Identity split: JS saves and the session model keep catalog keys (calpoker, spacepoker, krunk). The wire/WASM game_type is the first generated member’s initial_validation_program_hash, filled by factory warmup on page load (protocolIdForCatalog / catalogGameTypeFromWire).

Host contract: Packages implement GamePackage via games/host (HandProposal, factory-parameter codecs, durableState, one render(view) mount). Gameplay RxJS events are gone; the machine applies five inputs (hand-started, opponent-moved, game-message, move-rejected, hand-ended) and games dispatch GameIntent. Queued local actions persist as pending candidates separate from canonical handState until host-only LocalActionApplied.

Persistence: Session envelope is now v15 (WASM schema 6). Compose drafts live under drafts; last/retry/proposal-group terms become HandProposal and stay independent of the compose draft (null until a hand is agreed). Incompatible alpha records are still dropped, not migrated.

Adds GAME_WRITING_GUIDE.md as the add-a-game checklist.

Reviewed by Cursor Bugbot for commit 90e1615. Bugbot is set up for automated code reviews on this repo. Configure here.

…sion model.

Factory hashes stay on the WASM propose/notify boundary, and lastTerms is null until a hand is agreed so saves round-trip atomically.
The regression harness is a stub repo with only clsp/; GNU find exits 1 if a named search root does not exist.
Separate proposal composition, durable state, and play mounts so game UIs receive only accepted-hand data and host-owned lifecycle handling.
Comment thread front-end/src/hooks/useGameSession.ts Outdated
Give game packages one machine-owned state path and explicit directional contracts so live, restored, and frozen hands share the same authoritative model.
Comment thread front-end/src/lib/session/sessionMachineRuntime.ts Outdated
Comment thread games/spacepoker/ui/serialize.ts
Keep queued candidates separate from canonical game state so delayed acceptance and rejection remain correct across protocol replay and browser restore.
Comment thread front-end/src/lib/session/sessionMachineGame.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0ea4cba. Configure here.

Comment thread games/spacepoker/ui/useSpacepokerHand.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant